<include file="Public/header"/>
<include file="Public/menu"/>
<style>
    .order-edit li {
        list-style-type: none;
        cursor: pointer;
        padding: 0 4px;
        float: none;
        width: auto;
        text-align: right;
        font-size: 12px;
        line-height: 23px;
        height: 23px;
    }

    .order-edit li a {

        font-size: 12px;
    }

    .handle-order.active b {
        background: url('/Public/images/arrow-right.gif') no-repeat scroll 50% 50%;
        display: inline-block;
        width: 10px;
        height: 10px;
        vertical-align: center;

    }

    .handle-order b {
        background: url('/Public/images/arrow-down.gif') no-repeat scroll 50% 50%;
        display: inline-block;
        width: 10px;
        height: 10px;
        margin-left: 4px;
        vertical-align: center;
    }


</style>
<!-- 内容页 -->
<div class="content-wrapper">
    <!-- 面包屑 -->
    <section class="content-header">
        <h1>
            统计
            <small>商品销售统计</small>
        </h1>

    </section>

    <!-- 内容 -->
    <section class="content">

        <div class="row">
            <div class="col-md-12">
                <div class="nav-tabs-custom">
                    <ul class="nav nav-tabs">
                        <li <if condition="$view eq 0">class="active"</if> ><a href="/Admin/StoreGoodsSales/goodsSale/view/0.html">商品销售统计</a></li>
                        <li <if condition="$view eq 1">class="active"</if>><a href="/Admin/StoreItemSell/index/view/1.html">商品销售分类</a></li>
                        <li <if condition="$view eq 2">class="active"</if> ><a href="/Admin/StoreItemSell/index/view/2.html">商品销售排行Top100</a></li>
                        <li class="pull-right header"></li>
                    </ul>
                    <div class="tab-content">
                        <div class="box-header">
                            <h3 class="box-title"></h3>
                            <div class="form-inline pull-right">
                                <form id="search_form" name="search_form" action="/Admin/StoreItemSell/index/view/1.html" method="get">
                                    <fieldset>
                                        <input id="category" name="category" value="" type="hidden">
                                        <label class="input-group input-group-sm">商品分类</label>
                                        <div class="input-group input-group-sm">
                                            <select
                                                id="enableClickableOptGroups-onChange" multiple="multiple" class="multiselect-native-select">
                                                 <volist name="category" id="cat">
                                                    <optgroup label="{$cat.name}">
                                                        <foreach name="cat.sub_cat" item="value" key="key">
                                                            <option <if condition = "in_array($key, $selects)">selected</if> value="{$key}" >{$value}</option>
                                                        </foreach>
                                                    </optgroup>
                                                 </volist>
                                            </select>
                                        </div>
                                        <label class="input-group input-group-sm">日期选择</label>
                                        <div class="input-group input-group-sm isOrderChangeDate">
                                            <div class="input-group input-group-sm date form_datetime">

                                                <input id="begin_time" name="begin_time" class="form-control"
                                                       type="text" value="{$data.beginDate}" placeholder="开始日期" readonly/>
                                            </div>
                                            <div class="btn-group">-</div>
                                            <div class="input-group input-group-sm date">
                                                <input id="end_time" name="end_time" class="form-control" type="text"
                                                       value="{$data.endDate}" placeholder="结束日期" readonly/>
                                            </div>
                                        </div>
                                        <div class="input-group input-group-sm">
                                            <div class="input-group-btn">
                                                <button type="submit" class="btn btn-primary"><i
                                                        class="fa fa-search"></i></button>
                                            </div>
                                        </div>
                                    </fieldset>
                                </form>
                            </div>
                        </div>
                        <div class="tab-pane active" id="tab_0">
                            <div class="box">

                                <!-- /.box-header -->
                                <div class="box-body table-responsive no-padding">
                                    <table class="table table-hover table-view-list"
                                           style="overflow-x:scroll;margin-bottom:35px;">
                                        <tbody>
                                        <tr>
                                            <th>日期</th>
                                            <th>商品分类</th>
                                            <th>销售数量</th>
                                            <th>销售金额(￥)</th>
                                        </tr>
                                        <volist name="lists" id="list">
                                            <tr>
                                                <td>{$list.time}</td>
                                                <td>{$list.name}</td>
                                                <td>{$list.num}</td>
                                                <td>{$list.money}</td>
                                            </tr>
                                        </volist>
                                        </tbody>
                                    </table>
                                </div>
                                <div class="box-footer clearfix">

                                    <a class="btn btn-sm btn-primary grid-refresh" style="float: right"
                                       onclick="javascript:location.replace(location.href);"><i
                                            class="fa fa-refresh"></i></a>
                                    {$data.page}
                                </div>
                                <!-- /.box-body -->
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </section>
</div>
<!-- 底部 -->
<include file="Public/common_footer"/>
<script src="/Public/admin/jedate/jedate.js"></script>
<script src="/Public/admin/js/bootstrap-multiselect.js"></script>
<link rel="stylesheet" href="/Public/admin/jedate/jedate.css"/>
<link rel="stylesheet" href="/Public/admin/css/bootstrap-multiselect.css"/>
<script>
    initevents();
    function initevents() {
        var stype = $('#select_type').val();
        $('#isOrderChange').val(stype);
        if ($('#select_type').val() == 'createtime') {
            $('.isOrderChangeDate').show();
            $('#search_val').hide();
        }
    }

    function getBeforeDateStr() {
        var now = new Date();
        now = new Date(now.getTime() - 86400000);
        return now.getFullYear() + "-" + (now.getMonth() +1) + "-" + now.getDate();
    }

    function setJedate() {
        //不显示秒的解决办法
        var stxt = $("#begin_time").val().trim();
        if (stxt.length == 19) {
            $("#begin_time").val(stxt.substr(0, 16));
        }
        var etxt = $("#end_time").val().trim();
        if (etxt.length == 19) {
            $("#end_time").val(etxt.substr(0, 16));
        }
        var nowStr = getBeforeDateStr();
        // 获取当前时间
        var start = {
            dateCell: '#begin_time',
            format: 'YYYY-MM-DD',
            //minDate: nowStr + ' 00:00:00',
            festival: false,
            maxDate: nowStr,
            isinitVal: false,
            isTime: false,
            choosefun: function (datas) {
                end.minDate = datas;
            }
        };
        var end = {
            dateCell: '#end_time',
            format: 'YYYY-MM-DD',
            //minDate: nowStr + ' 00:00:00',
            festival: false,
            maxDate: nowStr,
            isinitVal: false,
            isTime: false,
            choosefun: function (datas) {
                start.maxDate = datas;
            }
        };
        jeDate(start);
        jeDate(end);
    }
    setJedate();
    $(function () {
        var _status = '{$msg.p}';
        //alert(_status);
        if (_status != '' && _status == 0) {
            $('input').attr('disabled', 'disabled');
        }
    });

    $(document).ready(function () {
        $('#enableClickableOptGroups-onChange').multiselect({
            nonSelectedText: '--选择分类--',
            allSelectedText: '全选',
            nSelectedText: '个分类被选中',
            delimiterText: ',',
            maxHeight:500,
            templates:{
                li:'<li style="margin-left: 16px"><a tabindex="0"><label></label></a></li>'
            },
            enableClickableOptGroups: true
        });
    });

</script>
<script data-exec-on-popstate>
    $(function () {
        setJedate();
        $("#search_form").validate({
            rules: {
                search_val: {
                    required: true,
                    maxlength: 140,
                },
            },
            messages: {
                search_val: {
                    required: "搜索内容不能为空",
                    maxlength: "搜索内容不能超过140个字符"
                }
            },
            submitHandler: function (form) {
                var selected = '', delimiter = ',';
                $('#enableClickableOptGroups-onChange option:selected').each(function () {
                    selected += $(this).val() + delimiter;
                });
                selected = selected.substr(0, selected.length - delimiter.length);
                $("#category").val();
                $("#category").val(selected);
                form.submit();   //提交表单
            }
        });
    });
    function ept() {
        $('#eid').submit();
    }
</script>
<script src="/Public/layer/layer.js"></script>
